package com.day.mapper;


import com.day.pojo.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface StudentMapper  {

    @Select("select student.*,school.s_name,classes.c_name,dormitory.d_name from student,school,classes,dormitory where school.s_id=student.s_id AND classes.c_id=student.c_id and dormitory.d_id=student.d_id")
    List<Student> getStudentList();

    @Select("select * from student where stu_id = #{stu_id}")
    Student getStudentById(Integer stu_id);

    @Insert("insert into student values (0,#{stu_name},#{stu_age},#{stu_sex},#{stu_phone},#{s_id},#{c_id},#{d_id})")
    void addStudent(Student student);

    @Delete("delete from student where stu_id = #{stu_id};")
    void delStudentById(Integer s_id);

    @Update("update student set stu_name = #{stu_name},stu_age = #{stu_age},stu_sex = #{stu_sex},stu_phone = #{stu_phone},s_id = #{s_id},c_id = #{c_id},d_id = #{d_id} where stu_id = #{stu_id}")
    void editStudentById(Student student);
}
